package com.woniu.controller;

import com.woniu.entity.InpatientDoctorOrder;
import com.woniu.service.IDoctorOrderService;
import com.woniu.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/doctor-order")
public class DoctorOrderController {
    @Resource
    private IDoctorOrderService iDoctorOrderService;
    //查看医嘱
    @GetMapping("/{patientId}")
    public ResponseUtil list(@PathVariable Integer patientId){
        ResponseUtil result = iDoctorOrderService.listDoctorOrders(patientId);
        return result;
    }
    //添加医嘱
    @PostMapping
    public ResponseUtil addRecord(@RequestBody InpatientDoctorOrder
                                          inpatientDoctorOrder) throws ParseException {
        ResponseUtil result = iDoctorOrderService
                .addRecord(inpatientDoctorOrder);
        return result;
    }
    //执行医嘱
    @PutMapping
    public ResponseUtil update(@RequestBody InpatientDoctorOrder
                                           inpatientDoctorOrder) throws ParseException {
        ResponseUtil result = iDoctorOrderService
                .updateRecord(inpatientDoctorOrder);
        return result;
    }
}
